unit ConnectSettings;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, IniFiles;

type
  TConnectSettingsF = class(TForm)
    GroupBox1: TGroupBox;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    LabeledEdit4: TLabeledEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure FormActivate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ConnectSettingsF: TConnectSettingsF;

implementation

{$R *.dfm}

Uses
  data;

procedure TConnectSettingsF.FormActivate(Sender: TObject);
begin
  LabeledEdit1.Text := server;
  LabeledEdit2.Text := userdb;
  LabeledEdit3.Text := passwd;
  LabeledEdit4.Text := base;
end;

procedure TConnectSettingsF.BitBtn1Click(Sender: TObject);
var
  iniFile: TIniFile;
begin
  iniFile := TIniFile.Create(progDir + 'config.ini');
  iniFile.WriteString('server', 'server', LabeledEdit1.Text);
  iniFile.WriteString('server', 'user', LabeledEdit2.Text);
  iniFile.WriteString('server', 'passwd', LabeledEdit3.Text);
  iniFile.WriteString('server', 'base', LabeledEdit4.Text);
  iniFile.Free;
  DataModule2.ZConnection1.Disconnect;
  DataModule2.ReadIni;
  Close;
end;

procedure TConnectSettingsF.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  action := caFree;
end;

procedure TConnectSettingsF.BitBtn2Click(Sender: TObject);
begin
  Close;
end;

end.
